<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends MY_Controller {
	function __construct() {
		parent::__construct();
		$this->load->model('model_product');
		$this->load->model('model_category');
		//$this->output->enable_profiler();
	}
	function index1()
	{
		$this->data['js'][] = config_item('asset').'js/jquery.easing.min.js';
		$this->data['js'][] = config_item('asset').'js/jquery.bxSlider.min.js';
		$this->data['js'][] = config_item('asset').'js/home.js';
			
		$this->render('welcome_tpl');
	}
	
	function detail($id = '', $title = '')
	{
//		$this->output->cache(10);
		$this->data['product'] = $this->model_product->get($id);
		if(empty($this->data['product'])){
			show_404();
		}
		$this->data['title'] = $this->data['product']['title'];
		$this->data['next'] = $this->model_product->get_next($id);
		$this->data['prev'] = $this->model_product->get_prev($id);
		$this->data['category'] = $this->model_category->get($this->data['product']['category_id']);
		
		$this->data['related_products'] = $this->model_product->get_related_product($id);
		
		$this->render('product/product_detail_tpl');
	}
	
	function index($cate_id = '',$title = '')
	{
		$this->data['products'] = $this->model_product->get_all($cate_id);
		if(!$this->input->is_ajax_request()){
			$this->data['categories'] = $this->model_category->get_all();
			$this->data['current_cate'] = $cate_id;
			$highlight = $this->model_product->get_product_highlight();
			if(!empty($highlight)){
				$this->data['highlight'] = $this->load->view('product/product_highlight_tpl', array('products'=>$highlight), true);
			}
			$this->render('product/product_index_tpl');
		}else{
			$this->load->view('product/product_index_tpl', $this->data);
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */